home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / fish / 001-100 / 001-025 / 001 / latffp / latffp.c < prev    next >
C/C++ Source or Header  |  1995-03-17  |  22KB  |  770 lines

  1. /*
  2.  * Article 633 of net.micro.amiga:
  3.  * ion: version B 2.10.2 9/17/84 chuqui version 1.9 3/12/85; site unisoft.UUCP
  4.  * Posting-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site amiga.amiga.UUCP
  5.  * Path: unisoft!dual!lll-crg!ucdavis!ucbvax!decvax!decwrl!pyramid!amiga!bobp
  6.  * From: bobp@amiga.UUCP (Robert S. Pariseau)
  7.  * Newsgroups: net.micro.amiga
  8.  * Subject: LatFFP program SOURCE (LONG!)
  9.  * Message-ID: <192@amiga.amiga.UUCP>
  10.  * Date: 6 Nov 85 03:53:01 GMT
  11.  * Date-Received: 17 Nov 85 21:40:30 GMT
  12.  * Reply-To: bobp@snake.UUCP (Robert S. Pariseau)
  13.  * Organization: Commodore-Amiga Inc., 983 University Ave #D, Los Gatos CA 95030
  14.  * Lines: 749
  15.  * 
  16.  * TITLE:  LatFFP program SOURCE (LONG!)
  17.  * 
  18.  * The program below shows how to access the Motorola Fast Floating Point
  19.  * libraries from V1.0 release Lattice C for the Amiga.  As you will see
  20.  * when you run it, the performance improvement gained by using the
  21.  * FFP routines (even in this kludgey fashion) is generally around a
  22.  * factor of 10!
  23.  * 
  24.  * Part of that improvement is just the difference in precision.  The
  25.  * Lattice stuff provides a 64 bit software implementation of the IEEE
  26.  * format.  The FFP stuff provides a 32 bit implementation of the
  27.  * Motorola format.
  28.  * 
  29.  * The variables used for FFP math are defined as ints.  You can't use
  30.  * FLOATs because V1.0 Lattice C converts FLOAT to DOUBLE during
  31.  * expression evaluation and when passing arguments.
  32.  * 
  33.  */
  34.  
  35. /*
  36.  * ------------------------Program Notes:
  37.  * 
  38.  * The program will compile and link cleanly using the stuff on the
  39.  * standard V1.0 Lattice C for Amiga disk.  The Make script in the
  40.  * examples directory will do all the work for you.  Since my C disk
  41.  * is rather full, and since I like the dramatic increase in speed,
  42.  * I usually do my work in ram disk as follows:
  43.  * 
  44.  *   1> cd df1:                               [my C disk]
  45.  *   1> copy examples/Make to :               [more convenient in root]
  46.  *   
  47.  *   1> copy LatFFP.c to ram:
  48.  *   1> execute Make ram:LatFFP
  49.  *   1> copy ram:LatFFP to df1:
  50.  * 
  51.  * I've also added a "stack 20000" command in my startup script
  52.  * (s/startup-sequence) to make sure I don't have to worry about stack
  53.  * overflows.
  54.  * 
  55.  * The program shows 3 bugs in the V1.0 stuff and includes one kludge.
  56.  * The bugs and kludge are maked in the source.  Bug (1): V1.0 Lattice
  57.  * C doesn't properly handle successive assignments of constants.  Use
  58.  * expressions.  Bug (2): V1.0 FFP doesn't correctly return a result
  59.  * from SPCmp().  Fake it with subtraction and SPTst() or write your
  60.  * own compare for now.  Bug (3): V1.0 FFP doesn't correctly return
  61.  * the cosine result from SPSincos().  Use SPCos() instead.
  62.  * 
  63.  * The kludge is the set of union definitions so that we can use the
  64.  * same variables for related Lattice and FFP expressions and for
  65.  * the conversions in and out of IEEE format.  Note that we use
  66.  * the Lattice IEEE based routines in printf() to get our output.
  67.  * 
  68.  * Note however, that the conversion routines are in the RAM based
  69.  * MathTrans library.  Therefore, if you only want to use the WCS
  70.  * based MathFFP library, you are on your own for conversion.
  71.  *
  72.  *------------------------Program Source Follows:
  73.  *
  74.  */
  75.  
  76.  
  77. /***********************************************************************
  78.  *  LatFFP -- Program to show the use of Motorola Fast Floating Point
  79.  *            math libraries with V1.0 Lattice C for the Amiga in
  80.  *            comparison to the DOUBLE precision IEEE floating point
  81.  *            math which is built in to the C.  The FFP format is
  82.  *            a 32 bit format.
  83.  *
  84.  *  Larry Hildenbrand -- Nov. 4, 1985
  85.  *  Bob Pariseau      -- Nov. 4, 1985  (minor editorial corrections)
  86.  *
  87.  ***********************************************************************/
  88.  
  89. #include <exec/types.h>
  90. #include <math.h>
  91.  
  92.  
  93. /* ??? #define   E      2.718281828459045 */  /* V1.0 Lattice C BUG!  See */
  94. #define   PIME   0.423310826                  /* below.  PIME == PI - E.  */
  95.  
  96.  
  97. /****  MAY BE BROKEN OUT INTO SEPARATE #include FILE ****/
  98.  
  99. extern   int     SPFix();
  100. extern   int     SPFlt();
  101. extern   int     SPCmp();
  102. extern   int     SPTst();
  103. extern   int     SPAbs();
  104. extern   int     SPNeg();
  105. extern   int     SPAdd();
  106. extern   int     SPSub();
  107. extern   int     SPMul();
  108. extern   int     SPDiv();
  109.  
  110. extern   int     SPAtan();
  111. extern   int     SPSin();
  112. extern   int     SPCos();
  113. extern   int     SPTan();
  114. extern   int     SPSincos();
  115. extern   int     SPSinh();
  116. extern   int     SPCosh();
  117. extern   int     SPTanh();
  118. extern   int     SPExp();
  119. extern   int     SPLog();
  120. extern   int     SPPow();
  121. extern   int     SPSqrt();
  122. extern   int     SPTieee();
  123. extern   int     SPFieee();
  124.  
  125. /********************************************************/
  126.  
  127.  
  128. char st1[80] = "3.1415926535897";
  129. char st2[80] = "2.718281828459045";
  130.  
  131.  
  132. int MathBase;        /* Basic FFP lib pointer */
  133. int MathTransBase;   /* Transcendental FFP lib pointer */
  134.  
  135. int dots_good = 0;
  136.  
  137.  
  138. union kludge1        /* Can't use FLOAT directly for FFP stuff */
  139. {                    /* because V1.0 Lattice converts FLOAT to */
  140.   FLOAT num1;        /* DOUBLE in expressions and when passing */
  141.   int   i1;          /* parameters.                            */
  142. } k1;
  143.  
  144. union kludge2
  145. {
  146.   FLOAT num2;
  147.   int   i2;
  148. } k2;
  149.  
  150. union kludge3
  151. {
  152.   FLOAT num3;
  153.   int   i3;
  154. } k3;
  155.  
  156. union kludge4
  157. {
  158.   FLOAT num4;
  159.   int   i4;
  160. } k4;
  161.  
  162. union kludge5
  163. {
  164.   FLOAT num5;
  165.   int   i5;
  166. } k5;
  167.  
  168. union kludge6
  169. {
  170.   FLOAT num6;
  171.   int   i6;
  172. } k6;
  173.  
  174.  
  175.  
  176. show_dot() { if( ++dots_good == 1000) { dots_good = 0; printf(".");} }
  177.  
  178.  
  179.  
  180. show_result( num ) FLOAT num; { printf("\nResult = %f", num); }
  181.  
  182.  
  183.  
  184. show_result_ffp(in_val)   /* Convert to IEEE and display */
  185.   int in_val;
  186. {
  187.   union kludge_sr
  188.   {
  189.     FLOAT new_iv_f;
  190.     int   new_iv_i;
  191.   } k;
  192.  
  193.   k.new_iv_i = SPTieee(in_val);
  194.   show_result(k.new_iv_f);
  195. }
  196.  
  197.  
  198.  
  199.  
  200. main()                  /* Lattice/FFP test code */
  201. {
  202.    UWORD i;
  203.    int i3;
  204.  
  205.    printf("C-ROM & Shared RAM Library Test Facility for the Amiga-Lattice Basic/Trans Math Libraries");
  206.  
  207. /*****************************************/
  208. /*****************************************/
  209. /***                                   ***/
  210. /***  OPEN ROM AND RAM FFP LIBRARIES   ***/
  211. /***                                   ***/
  212. /*****************************************/
  213. /*****************************************/
  214.  
  215.    if((MathBase = OpenLibrary("mathffp.library", 0)) < 1 ) {
  216.        printf("\n\n*** ERROR ***  Can't open mathffp.library: vector = %lx\n", MathBase);
  217.        exit();
  218.    }
  219.    else {
  220.        printf("\n\nSuccessfully opened mathffp.library: vector = %lx\n", MathBase);
  221.    }
  222.  
  223.    if((MathTransBase = OpenLibrary("mathtrans.library", 0)) < 1 ) {
  224.        printf("\n\n*** ERROR ***  Can't open mathtrans.library: vector = %lx\n", MathTransBase);
  225.        CloseLibrary(MathBase);
  226.        exit();
  227.    }
  228.    else {
  229.        printf("\n\nSuccessfully opened mathtrans.library: vector = %lx\n", MathTransBase);
  230.    }
  231.  
  232.  
  233. /*****************************************/
  234. /*****************************************/
  235. /***                                   ***/
  236. /***  COMPILER & FFP S.P. ADDITION     ***/
  237. /***                                   ***/
  238. /*****************************************/
  239. /*****************************************/
  240.  
  241.    k1.num1 = PI;                  /* V1.0 Lattice C BUG!  Can't have two  */
  242.    k2.num2 = k1.num1 - PIME;      /* constant assignments in a row.  Fake */
  243.                                   /* it by making the second be an        */
  244.                                   /* expression!                          */
  245.  
  246.  
  247.    printf("\n\n50,000 additions of %s to %s (Compiler Interface)\n", st1, st2);
  248.    for( dots_good = 0, i= 1; i < 50000; i++ )
  249.    {
  250.       k3.num3 = k1.num1 + k2.num2;
  251.       show_dot();
  252.    }
  253.    show_result( k3.num3 );
  254.  
  255.  
  256.    k1.i1 = SPFieee(k1.i1);
  257.    k2.i2 = SPFieee(k2.i2);
  258.  
  259.    printf("\n\n50,000 additions of %s to %s (Function Interface)\n", st1, st2 );
  260.    for( dots_good = 0, i= 1; i < 50000; i++ )
  261.    {
  262.       k3.i3 = SPAdd(k2.i2, k1.i1);
  263.       show_dot();
  264.    }
  265.    show_result_ffp( k3.i3 );
  266.  
  267.  
  268. /*****************************************/
  269. /*****************************************/
  270. /***                                   ***/
  271. /***  COMPILER & FFP S.P. SUBTRACTION  ***/
  272. /***                                   ***/
  273. /*****************************************/
  274. /*****************************************/
  275.  
  276.    k1.num1 = PI;
  277.    k2.num2 = k1.num1 - PIME;
  278.  
  279.    printf("\n\n50,000 subtractions of %s from %s (Compiler Interface)\n", st1, st2 );
  280.    for( dots_good = 0, i= 1; i < 50000; i++ )
  281.    {
  282.       k3.num3 = k2.num2 - k1.num1;
  283.       show_dot();
  284.    }
  285.    show_result( k3.num3 );
  286.  
  287.  
  288.    k1.i1 = SPFieee(k1.i1);
  289.    k2.i2 = SPFieee(k2.i2);
  290.  
  291.    printf("\n\n50,000 subtractions of %s from %s (Function Interface)\n", st1, st2 );
  292.    for( dots_good = 0, i= 1; i < 50000; i++ )
  293.    {
  294.       k3.i3 = SPSub(k1.i1, k2.i2);
  295.       show_dot();
  296.    }
  297.    show_result_ffp( k3.i3 );
  298.  
  299.    
  300. /*****************************************/
  301. /*****************************************/
  302. /***                                   ***/
  303. /***  COMPILER & FFP S.P. MULTIPLYS    ***/
  304. /***                                   ***/
  305. /*****************************************/
  306. /*****************************************/
  307.  
  308.    k1.num1 = PI;
  309.    k2.num2 = k1.num1 - PIME;
  310.  
  311.    printf("\n\n50,000 multiplies of %s by %s (Compiler Interface)\n", st1, st2 );
  312.    for( dots_good = 0, i= 1; i < 50000; i++ )
  313.    {
  314.       k3.num3 = k1.num1 * k2.num2;
  315.       show_dot();
  316.    }
  317.    show_result( k3.num3 );
  318.    
  319.  
  320.    k1.i1 = SPFieee(k1.i1);
  321.    k2.i2 = SPFieee(k2.i2);
  322.  
  323.    printf("\n\n50,000 multiplies of %s by %s (Function Interface)\n", st1, st2 );
  324.    for( dots_good = 0, i= 1; i < 50000; i++ )
  325.    {
  326.       k3.i3 = SPMul(k2.i2, k1.i1);
  327.       show_dot();
  328.    }
  329.    show_result_ffp( k3.i3 );
  330.  
  331.  
  332. /*****************************************/
  333. /*****************************************/
  334. /***                                   ***/
  335. /***  COMPILER & FFP S.P. DIVISION     ***/
  336. /***                                   ***/
  337. /*****************************************/
  338. /*****************************************/
  339.  
  340.    k1.num1 = PI;
  341.    k2.num2 = k1.num1 - PIME;
  342.  
  343.    printf("\n\n50,000 divides of %s by %s (Compiler Interface)\n", st1, st2 );
  344.    for( dots_good = 0, i= 1; i < 50000; i++ )
  345.    {
  346.       k3.num3 = k1.num1 / k2.num2;
  347.       show_dot();
  348.    }
  349.    show_result( k3.num3 );
  350.  
  351.  
  352.    k1.i1 = SPFieee(k1.i1);
  353.    k2.i2 = SPFieee(k2.i2);
  354.  
  355.    printf("\n\n50,000 divides of %s by %s (Function Interface)\n", st1, st2 );
  356.    for( dots_good = 0, i= 1; i < 50000; i++ )
  357.    {
  358.       k3.i3 = SPDiv(k2.i2, k1.i1);
  359.       show_dot();
  360.    }
  361.    show_result_ffp( k3.i3 );
  362.  
  363.  
  364. /*****************************************/
  365. /*****************************************/
  366. /***                                   ***/
  367. /***  COMPILER & FFP S.P. TRUNCATION   ***/
  368. /***                                   ***/
  369. /*****************************************/
  370. /*****************************************/
  371.  
  372.    k1.num1 = PI;
  373.    k2.num2 = k1.num1 - PIME;
  374.  
  375.    printf("\n\n50,000 fixes of %s (Compiler Interface)\n", st1 );
  376.    for( dots_good = 0, i= 1; i < 50000; i++ )
  377.    {
  378.       i3 = (int) k1.num1;
  379.       if( ++dots_good == 1000) { dots_good = 0; printf(".");}
  380.    }
  381.    printf("\nResult = %d", i3 );
  382.  
  383.  
  384.    k1.i1 = SPFieee(k1.i1);
  385.    k2.i2 = SPFieee(k2.i2);
  386.  
  387.    printf("\n\n50,000 fixes of %s (Function Interface)\n", st1 );
  388.    for( dots_good = 0, i= 1; i < 50000; i++ )
  389.    {
  390.       i3 = SPFix(k1.i1);
  391.       if( ++dots_good == 1000) { dots_good = 0; printf(".");}
  392.    }
  393.    printf("\nResult = %d", i3);
  394.  
  395.  
  396. /*****************************************/
  397. /*****************************************/
  398. /***                                   ***/
  399. /***  COMPILER & FFP S.P. FLOATATION   ***/
  400. /***                                   ***/
  401. /*****************************************/
  402. /*****************************************/
  403.  
  404.    i3 = 5;
  405.  
  406.    printf("\n\n50,000 floats of %d (Compiler Interface)\n", i3 );
  407.    for( dots_good = 0, i= 1; i < 50000; i++ )
  408.    {
  409.        k4.num4 = (FLOAT) i3;
  410.       show_dot();
  411.    }
  412.    show_result( k4.num4 );
  413.  
  414.  
  415.    printf("\n\n50,000 floats of %d (Function Interface)\n", i3 );
  416.    for( dots_good = 0, i= 1; i < 50000; i++ )
  417.    {
  418.        k4.i4 = SPFlt(i3);
  419.       show_dot();
  420.    }
  421.    show_result_ffp( k4.i4 );
  422.  
  423.  
  424. /*****************************************/
  425. /*****************************************/
  426. /***                                   ***/
  427. /***  COMPILER & FFP S.P. NEGATION     ***/
  428. /***                                   ***/
  429. /*****************************************/
  430. /*****************************************/
  431.  
  432.    k1.num1 = PI;
  433.    k2.num2 = k1.num1 - PIME;
  434.  
  435.    printf("\n\n50,000 negates of %s (Compiler Interface)\n", st2 );
  436.    for( dots_good = 0, i= 1; i < 50000; i++ )
  437.    {
  438.       k4.num4 = -k2.num2;
  439.       show_dot();
  440.    }
  441.    show_result( k4.num4 );
  442.  
  443.  
  444.    k1.i1 = SPFieee(k1.i1);
  445.    k2.i2 = SPFieee(k2.i2);
  446.  
  447.    printf("\n\n50,000 negates of %s (Function Interface)\n", st2 );
  448.    for( dots_good = 0, i= 1; i < 50000; i++ )
  449.    {
  450.       k4.i4 = SPNeg(k2.i2);
  451.       show_dot();
  452.    }
  453.    show_result_ffp( k4.i4 );
  454.  
  455.  
  456. /*****************************************/
  457. /*****************************************/
  458. /***                                   ***/
  459. /***  COMPILER & FFP S.P. ABSOLUTE VAL ***/
  460. /***                                   ***/
  461. /*****************************************/
  462. /*****************************************/
  463.  
  464.    k1.num1 = PI;
  465.    k4.num4 = PIME - k1.num1;
  466.  
  467.    printf("\n\n50,000 absolute values of %f (Compiler Interface)\n", k4.num4 );
  468.    for( dots_good = 0, i= 1; i < 50000; i++ )
  469.    {
  470.       k5.num5 = fabs(k4.num4);
  471.       show_dot();
  472.    }
  473.    show_result( k5.num5 );
  474.  
  475.  
  476.    printf("\n\n50,000 absolute values of %f (Function Interface)\n", k4.num4 );
  477.    k4.i4 = SPFieee(k4.i4);
  478.    for( dots_good = 0, i= 1; i < 50000; i++ )
  479.    {
  480.       k5.i5 = SPAbs(k4.i4);
  481.       show_dot();
  482.    }
  483.    show_result_ffp( k5.i5 );
  484.  
  485.  
  486.    printf("\n\n*** HIT RETURN TO CONTINUE ***");   getch();
  487.  
  488.  
  489. /*****************************************/
  490. /*****************************************/
  491. /***                                   ***/
  492. /***  COMPILER & FFP S.P. COMPARE      ***/
  493. /***                                   ***/
  494. /*****************************************/
  495. /*****************************************/
  496.  
  497.    k1.num1 = PI;
  498.    k2.num2 = k1.num1 - PIME;
  499.  
  500.    if (k2.num2 >= k1.num1)
  501.       printf("\n\n%f is greater than or equal to %f (Compiler Interface)\n", k2.num2, k1.num1);
  502.    else
  503.       printf("\n\n%f is less than %f (Compiler Interface)\n", k2.num2, k1.num1);
  504.  
  505.  
  506.    k1.i1 = SPFieee(k1.i1);
  507.    k2.i2 = SPFieee(k2.i2);
  508.  
  509.    printf("\n*** SPCmp(k2.i2, k1.i1) returned %d ***", SPCmp(k2.i2, k1.i1));
  510.  
  511.  
  512.    if (SPCmp(k2.i2, k1.i1))     /* V1.0 FFP Bug.  SPCmp() broken. */
  513.  
  514.    {  k1.num1 = PI;
  515.       k2.num2 = k1.num1 - PIME;
  516.       printf("\n\n%f is greater than or equal to %f (Function Interface)\n", k2.num2, k1.num1);
  517.    }
  518.    else
  519.    {  k1.num1 = PI;
  520.       k2.num2 = k1.num1 - PIME;
  521.       printf("\n\n%f is less than %f (Function Interface)\n", k2.num2, k1.num1);
  522.    }
  523.  
  524.  
  525.    if (k1.num1 >= k2.num2)
  526.       printf("\n\n%f is greater than or equal to %f (Compiler Interface)\n", k1.num1, k2.num2);
  527.    else
  528.       printf("\n\n%f is less than %f (Compiler Interface)\n", k1.num1, k2.num2);
  529.  
  530.  
  531.    k1.i1 = SPFieee(k1.i1);
  532.    k2.i2 = SPFieee(k2.i2);
  533.  
  534.    if (SPCmp(k1.i1, k2.i2))
  535.    {  k1.num1 = PI;
  536.       k2.num2 = k1.num1 - PIME;
  537.       printf("\n\n%f is greater than or equal to %f (Function Interface)\n", k1.num1, k2.num2);
  538.    }
  539.    else
  540.    {  k1.num1 = PI;
  541.       k2.num2 = k1.num1 - PIME;
  542.       printf("\n\n%f is less than %f (Function Interface)\n", k1.num1, k2.num2);
  543.    }
  544.  
  545.  
  546. /*****************************************/
  547. /*****************************************/
  548. /***                                   ***/
  549. /***  COMPILER & FFP S.P. TEST         ***/
  550. /***                                   ***/
  551. /*****************************************/
  552. /*****************************************/
  553.  
  554.    if (k2.num2)
  555.       printf("\n\n%f is not equal to 0.0 (Compiler Interface)\n", k2.num2);
  556.    else
  557.       printf("\n\n%f is equal to 0.0 (Compiler Interface)\n", k2.num2);
  558.  
  559.  
  560.    k2.i2 = SPFieee(k2.i2);
  561.  
  562.    if (SPTst(k2.i2))
  563.    {  k1.num1 = PI;
  564.       k2.num2 = k1.num1 - PIME;
  565.       printf("\n\n%f is not equal to 0.0 (Function Interface)\n", k2.num2);
  566.    }
  567.    else
  568.    {  k1.num1 = PI;
  569.       k2.num2 = k1.num1 - PIME;
  570.       printf("\n\n%f is equal to 0.0 (Function Interface)\n", k2.num2);
  571.    }
  572.  
  573.  
  574.    k2.num2 = 0.0;
  575.  
  576.    if (k2.num2)
  577.       printf("\n\n%f is not equal to 0.0 (Compiler Interface)\n", k2.num2);
  578.    else
  579.       printf("\n\n%f is equal to 0.0 (Compiler Interface)\n", k2.num2);
  580.  
  581.  
  582.    k2.i2 = SPFieee(k2.i2);
  583.  
  584.    if (SPTst(k2.i2))
  585.    {  k2.num2 = 0.0;
  586.       printf("\n\n%f is not equal to 0.0 (Function Interface)\n", k2.i2);
  587.    }
  588.    else
  589.    {  k2.num2 = 0.0;
  590.       printf("\n\n%f is equal to 0.0 (Function Interface)\n", k2.i2);
  591.    }
  592.  
  593.  
  594. /*****************************************/
  595. /*****************************************/
  596. /***                                   ***/
  597. /***  FFP S.P. SQUARE ROOT             ***/
  598. /***                                   ***/
  599. /*****************************************/
  600. /*****************************************/
  601.  
  602.    k1.num1 = PI;
  603.    k2.num2 = k1.num1 - PIME;
  604.  
  605.    printf("\n\n50,000 square roots of %f\n", k2.num2);
  606.    k1.i1 = SPFieee(k1.i1);
  607.    k2.i2 = SPFieee(k2.i2);
  608.    for( dots_good = 0, i= 1; i < 50000; i++ )
  609.    {
  610.       k3.i3 = SPSqrt( k2.i2 );
  611.       show_dot();
  612.    }
  613.    show_result_ffp( k3.i3 );
  614.  
  615.  
  616. /*****************************************/
  617. /*****************************************/
  618. /***                                   ***/
  619. /***  FFP S.P. NATURAL LOGARITHM       ***/
  620. /***                                   ***/
  621. /*****************************************/
  622. /*****************************************/
  623.  
  624.    printf("\n\n40,000 logarithms of %s\n", st1 );
  625.    for( dots_good = 0, i= 1; i < 40000; i++ )
  626.    {
  627.       k3.i3 = SPLog( k1.i1 );
  628.       show_dot();
  629.    }
  630.    show_result_ffp( k3.i3 );
  631.  
  632.  
  633. /*****************************************/
  634. /*****************************************/
  635. /***                                   ***/
  636. /***  FFP S.P. EXPONENT (BASE e)       ***/
  637. /***                                   ***/
  638. /*****************************************/
  639. /*****************************************/
  640.  
  641.    printf("\n\n40,000 exponents of %s\n", st1 );
  642.    for( dots_good = 0, i= 1; i < 40000; i++ )
  643.    {
  644.       k3.i3 = SPExp( k1.i1 );
  645.       show_dot();
  646.    }
  647.    show_result_ffp( k3.i3 );
  648.  
  649.  
  650. /*****************************************/
  651. /*****************************************/
  652. /***                                   ***/
  653. /***  FFP S.P. SINE, COSINE & TANGENT  ***/
  654. /***                                   ***/
  655. /*****************************************/
  656. /*****************************************/
  657.  
  658.    k1.num1 = PI;
  659.    k2.num2 = k1.num1 - PIME;
  660.    k1.num1 = k1.num1 / 6.0;
  661.    k1.i1 = SPFieee(k1.i1);
  662.    k2.i2 = SPFieee(k2.i2);
  663.  
  664.    printf("\n\n20,000 sines, cosines and tangents of %s / 6 radians\n", st1 );
  665.    for( dots_good = 0, i= 1; i < 20000; i++ )
  666.    {
  667.       k2.i2 = SPSin(k1.i1);
  668.       k3.i3 = SPCos(k1.i1);
  669.       k4.i4 = SPTan(k1.i1);
  670.       k5.i5 = SPSincos(&k6.i6, k1.i1);  /* V1.0 FFP BUG!  Cosine return  */
  671.                                         /* value (k6.i6) of SPSincos is  */
  672.                                         /* broken.  Function result      */
  673.                                         /* (sine -- k5.i5) is OK.        */
  674.  
  675.       show_dot();
  676.    }
  677.    show_result_ffp( k2.i2 );   show_result_ffp( k3.i3 );
  678.    show_result_ffp( k4.i4 );
  679.    show_result_ffp( k5.i5 );   show_result_ffp( k6.i6 );
  680.  
  681.  
  682. /*****************************************/
  683. /*****************************************/
  684. /***                                   ***/
  685. /***  FFP S.P. ARCTANGENT              ***/
  686. /***                                   ***/
  687. /*****************************************/
  688. /*****************************************/
  689.  
  690.    printf("\n\n20,000 arctangents of the tangent of %s / 6 radians\n", st1 );
  691.    for( dots_good = 0, i= 1; i < 20000; i++ )
  692.    {
  693.       k2.i2 = SPAtan(k4.i4);
  694.       show_dot();
  695.    }
  696.    show_result_ffp( k2.i2 );
  697.  
  698.  
  699. /***************************************************/
  700. /***************************************************/
  701. /***                                             ***/
  702. /***  FFP S.P. HYPERBOLIC SINE, COSINE & TANGENT ***/
  703. /***                                             ***/
  704. /***************************************************/
  705. /***************************************************/
  706.  
  707.    k1.num1 = PI;
  708.    k2.num2 = k1.num1 - PIME;
  709.    k1.i1 = SPFieee(k1.i1);
  710.    k2.i2 = SPFieee(k2.i2);
  711.  
  712.    printf("\n\n20,000 hyperbolic sines, cosines and tangents of %s radians\n", st1 );
  713.    for( dots_good = 0, i= 1; i < 20000; i++ )
  714.    {
  715.       k2.i2 = SPSinh( k1.i1 );
  716.       k3.i3 = SPCosh( k1.i1 );
  717.       k4.i4 = SPTanh( k1.i1 );
  718.       show_dot();
  719.    }
  720.    show_result_ffp( k2.i2 );   show_result_ffp( k3.i3 );   show_result_ffp( k4.i4 );
  721.  
  722.  
  723. /*****************************************/
  724. /*****************************************/
  725. /***                                   ***/
  726. /***  FFP S.P. POWER FUNCTION          ***/
  727. /***                                   ***/
  728. /*****************************************/
  729. /*****************************************/
  730.  
  731.    k1.num1 = PI;
  732.    k2.num2 = k1.num1 - PIME;
  733.    k1.i1 = SPFieee(k1.i1);
  734.    k2.i2 = SPFieee(k2.i2);
  735.  
  736.    printf("\n\n10,000 %s raised to the %s power\n", st1, st2 );
  737.    for( dots_good = 0, i= 1; i < 10000; i++ )
  738.    {
  739.       k3.i3 = SPPow( k2.i2, k1.i1 );
  740.       show_dot();
  741.    }
  742.    show_result_ffp( k3.i3 );
  743.  
  744.  
  745. /*****************************************/
  746. /*****************************************/
  747. /***                                   ***/
  748. /***  CLOSE ROM AND RAM FFP LIBRARIES  ***/
  749. /***                                   ***/
  750. /*****************************************/
  751. /*****************************************/
  752.  
  753.    RemLibrary(MathTransBase);    /* Mark lib for Expunge() from RAM upon  */
  754.                                  /* CloseLibrary() by last opener.  Else  */
  755.                                  /* lib stays in RAM for others to use    */
  756.                                  /* quickly (no need to go to disk) until */
  757.                                  /* AllocMem() finds it needs the memory  */
  758.                                  /* for some other purpose.               */
  759.   
  760.    CloseLibrary(MathTransBase);  /* Close transcendental math RAM library */
  761.  
  762.  
  763.  
  764.    CloseLibrary(MathBase);       /* Close basic math ROM library */
  765.  
  766.  
  767.    printf("\n\nEnd C-ROM & Shared RAM Library Test (LATTICE) \n");
  768. }
  769.  
  770.